Fix worktree-rm: detect squash-merged branches via GitHub PR status#123
Merged
Fix worktree-rm: detect squash-merged branches via GitHub PR status#123
Conversation
…deleting git branch -d fails to detect squash-merged branches because the commit hashes differ. Replace the single git branch -d with a 3-step approach: 1. Fetch origin to update tracking refs (best-effort) 2. Query GitHub via gh pr view for PR merge status 3. Force-delete (-D) when GitHub confirms merge; safe-delete (-d) otherwise This handles squash merges, rebase merges, and stale local refs while degrading gracefully when gh is unavailable or offline. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
Overall assessment: Executive summary:
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
…ame confusion gh pr view "$BRANCH" interprets numeric branch names (e.g., 1234) as PR numbers, which could cause force-deletion of an unrelated branch's work. Switch to gh pr list --head which always queries by branch name. Also handle the new empty-output case when no PR exists for the branch. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Owner
Author
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall assessment: Executive summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
Use --state merged for unambiguous multi-PR handling and add upstream-ahead check to prevent force-deleting local-only commits. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Owner
Author
|
/ai-review |
|
🔁 AI review rerun (requested by @igerber) Head SHA: Overall assessment: ✅ Looks good Executive summary
Methodology
Code Quality
Performance
Maintainability
Tech Debt
Security
Documentation/Tests
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
git branch -din worktree-rm step 6 with a 3-step approach that queries GitHub firstgit fetch origin(best-effort) to update tracking refs before branch deletiongh pr viewcheck to detect squash merges, rebase merges, and regular merges via GitHub API-D) when GitHub confirms PR was merged; safe-delete (-d) otherwiseghis unavailable, offline, or no PR exists for the branchMethodology references (required if estimator / math changes)
Validation
ghunavailableSecurity / privacy
Generated with Claude Code